<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="javax.servlet.http.*" %>
<%@page import="java.text.DecimalFormat" %>
<%@page import="nespresso.beans.*" %>
<%@page import="org.apache.commons.logging.*" %>
<html>

<head>
<title>NESPRESSO</title>
<link rel="stylesheet" type="text/css" href="css/nespresso.css" />
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/jquery.dd.js" type="text/javascript"></script>
<script src="js/jquery.validationEngine.js" type="text/javascript"></script>
<script src="js/jquery.validationEngine-fr.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="css/dd.css" />
<link rel="stylesheet" type="text/css" href="css/validationEngine.jquery.css" />

<script src="js/jquery.alerts.js" type="text/javascript"></script>

<link rel="stylesheet" type="text/css" href="css/jquery.alerts.css" />


</head>

<body>
<% Ligne l = (Ligne)session.getAttribute("lignesel");
   session.setAttribute("lignesel", l);
   Commande c = (Commande)session.getAttribute("commande");
   if(l == null) { %>Ligne nulle<% }
   if(c == null) { %>Commande nulle <% }
   Log log = LogFactory.getLog(this.getClass());%>
<div class="super-div">
<p>&nbsp;</p>
<table border="0" width="100%" align="center">
    <tr>
        <td>
            <p align="center"><strong>
            <font class="grosnoir">Commande N&#176;</font><font class="grosrouge"> <%=c.GetId() %></font>
            <font class="grosnoir">- Ligne N&#176; </font><font class="grosrouge"><%=l.GetId() %></font></strong></p>
        </td>
    </tr>
    <tr>
        <td>
            <p align="center"><font class="petitnoir">Pour : </font><font class="petitbleu"><%=l.GetNomprenom() %></font></p>
        </td>
    </tr>
</table>
<p>&nbsp;</p>
<div class="divrondform" style="width:800; margin:auto">
<form name="FLigne" id="FLigne" action="Ligne" class="f" method="post">
    <table border="0" width="80%" height="132" align="center">
		<tr><td height="20" width="148"></td><td height="20" width="265"></td><td height="20" width="140"></td></tr>
        <tr>            <td width="148">
                <p align="right">Capsule :</p>
            </td>
            <td width="265"><select name="capsules" id="capsules" size="1" style="width:180px">
            <% int g = 34;
               String sel = new String("selected=" + (char)g + "selected" + (char)g);
               Base cap = new Base();
               cap.GetResultat("capsules");
               while(cap.Suivant()) { %>
                	<option value="<%=cap.GetTexte("id") %>" <%
                    if(cap.GetTexte("image") != null) %> title="icons/<%=cap.GetTexte("image") %>" <%;
                    if(cap.GetTexte("ID").equals(l.GetIdcapsule())) out.write(sel); %>>
                    <%=cap.GetTexte("NOM") %> </option><%
               }
              cap.Free(); %>
			</select></td>
            <td width="140">
                <p><input class="boutons" type="submit" id="bMiseAJour" name="BValideLigne" value="Mise &agrave; jour"></p>
            </td>
        </tr>
        <tr>            <td width="148">
                <p align="right">Nombre : </p>
            </td>
            <td width="265"><input type="text" name="nbcapsules" id="nbcapsules" maxlength="3" size="3" class="validate[required,custom[onlyNumberSp]]"
            value="<%=l.GetNbcapsule() %>"></td>
            <td width="140">
                <p><input class="boutons" type="submit" id="bSupprimer" name="BValideLigne" value="Supprimer"></p>
            </td>
        </tr>
        <tr>            <td width="148">
                <p align="right">Prix unitaire :</p>
            </td>
            <td width="265" name="puht"><%=l.GetMontant() / (l.GetNbcapsule() * 10) %>&#128;&nbsp;X&nbsp;10&nbsp;</td>
            <td width="140">
                <p><input class="boutons" type="button" value="Retour" onclick="javascript:location.href='lignescommande.jsp'"></p>
            </td>
        </tr>
        <tr>            <td width="148">
                <p align="right">Total :</p>
            </td>
            <td width="265"name="total"><%=new DecimalFormat("0.00").format(l.GetMontant()) %>&#128;</td>
            <td width="140">&nbsp;</td>
        </tr>
		<tr><td height="20" width="148"></td><td height="20" width="265"></td><td height="20" width="140"></td></tr>
    </table>
</form>
</div>
</div>
<script>

$(document).ready(function(e) {
	var sup = null;
	
	// Liste d�roulante avec images
	try {
		$("#capsules").msDropDown();
	} catch(e) {
		alert(e.message);
	}
	
	// Popups indiquant les erreurs
	$("#FLigne").validationEngine({promptPosition : "centerRight", scroll: false, validationEventTrigger: "blur"});
	
	// Confirmation du bouton "Supprimer"
	$("input#bSupprimer").click(function() {
		if(sup == null)	sup = "sup"; else sup = null;
	});
	
	$('form#FLigne').submit(function(e){
		if(sup == "sup") {
	    	e.preventDefault();
	    	jConfirm("Confirmez-vous la suppression de la ligne ?", "confirmation", function(result){
	    		if(result) $('input#bSupprimer').click(); else sup = null;
	   		});
		}
	});
});

document.getElementById('nbcapsules').focus();
</script>
</body>

</html>